\ProvidesPackage{beamerouterthemeict}[2006/11/13]

% Copyright 2006 by Zhang Sen <zhangsen@ict.ac.cn>

% This beamer template for Institute of Computing Technology, CAS.
% This beamer template is based on the template of
% NTNU: http://story.idi.ntnu.no/~cassens/blog/archives/39-A-Beamer-theme-for-NTNU.html
% What follows are its original Copyright message.
% Copyright 2003      by Till Tantau   <tantau@users.sourceforge.net>
%       and 2005-2006 by Joerg Cassens <jmt@cassens.org>
%
% Bug fixes 2006      by Helge Langseth
%       and 2006      by Jyun-Fan Tsai
%
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 2.


\mode<presentation>

\pgfdeclareimage[height=2em,interpolate=true]{ictlogotext}{ict/ictlogo3}

\ifbeamer@nynorsk
  \pgfdeclareimage[height=2em,interpolate=true]{ictlogotext}{ict/nynorsk-logo}
\fi

\ifbeamer@bokmaal
  \pgfdeclareimage[height=2em,interpolate=true]{ictlogotext}{ict/bokmaal-logo}
\fi

\ifbeamer@mylogo
  \pgfdeclareimage[height=2em,interpolate=true]{ictlogotext}{ict/mylogo}
\fi

\ifbeamer@ictlogo
  \pgfdeclareimage[height=2em,interpolate=true]{ictlogotext}{ict/ictlogo}
\fi
\ifbeamer@nologo
  \titlegraphic{\pgfuseimage{ictlogotext}}
\fi

% The first part is based on the split theme

\setbeamercolor{section in head/foot}{parent=palette primary}
\setbeamercolor{subsection in head/foot}{parent=palette secondary}

\setbeamercolor{author in head/foot}{parent=section in head/foot}
\setbeamercolor{title in head/foot}{parent=subsection in head/foot}

\setbeamercolor{date in head/foot}{parent=palette tertiary}

\usesectionheadtemplate
  {\hfill\insertsectionhead}
  {\hfill\color{fg!50!bg}\insertsectionhead}

% Head
\ifbeamer@compress
  \defbeamertemplate*{headline}{ict theme}
  {%
    \leavevmode%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,right]{section in head/foot}%
      \usebeamerfont{section in head/foot}\insertsectionhead\hspace*{2ex}
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,left]{subsection in head/foot}%
      \usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertsubsectionhead
    \end{beamercolorbox}%
  }

\else

  \ifbeamer@minimal
    \defbeamertemplate*{headline}{ict theme}{}

  \else
    \defbeamertemplate*{headline}{ict theme}
    {%
      \leavevmode%
      \@tempdimb=2.4375ex%
      \ifnum\beamer@subsectionmax<\beamer@sectionmax%
        \multiply\@tempdimb by\beamer@sectionmax%
      \else%
        \multiply\@tempdimb by\beamer@subsectionmax%
      \fi%
      \ifdim\@tempdimb>0pt%
        \advance\@tempdimb by 1.125ex%
        \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{section in head/foot}%
          \vbox to\@tempdimb{\vfil\insertsectionnavigation{.5\paperwidth}\vfil}%
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
          \vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.5\paperwidth}\vfil}%
        \end{beamercolorbox}%
      \fi%
    }

  \fi

\fi

\ifbeamer@numbers

\defbeamertemplate*{footline}{ict theme}
{%
  \leavevmode%
  \hbox{\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertframenumber{}\hfill\insertshortauthor
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}}%
  \vskip0pt%
}

% as an alternative to putting the pagenumber in the corner, we can put it in the center

% {%
%   \leavevmode%
%   \hbox{\begin{beamercolorbox}[wd=.45\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm plus1fill,rightskip=.3cm]{author in head/foot}%
%     \usebeamerfont{author in head/foot}\insertshortauthor
%   \end{beamercolorbox}%
%   \begin{beamercolorbox}[wd=.1\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm,center]{date in head/foot}%
%     \usebeamerfont{date in head/foot}\insertframenumber{}
%   \end{beamercolorbox}%
%   \begin{beamercolorbox}[wd=.45\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
%     \usebeamerfont{title in head/foot}\insertshorttitle
%   \end{beamercolorbox}}%
%   \vskip0pt%
% }

\else

\defbeamertemplate*{footline}{ict theme}
{%
  \leavevmode%
  \hbox{\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm plus1fill,rightskip=.3cm]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}}%
  \vskip0pt%
}

\fi

% this part is based on the shadow theme

\setbeamercolor{frametitle}{parent=subsection in head/foot}
\setbeamercolor{frametitle right}{parent=section in head/foot}


\pgfdeclarehorizontalshading[frametitle.bg,frametitle right.bg]{beamer@frametitleshade}{\paperheight}{%
  color(0pt)=(frametitle.bg);
  color(\paperwidth)=(frametitle right.bg)}

\AtBeginDocument{
  \pgfdeclareverticalshading{beamer@topshade}{\paperwidth}{%
    color(0pt)=(bg);
    color(4pt)=(black!50!bg)}
}

\addtobeamertemplate{headline}
{}
{%
  \vskip-0.2pt
  \pgfuseshading{beamer@topshade}
  \vskip-2pt
}


\defbeamertemplate*{frametitle}{ict theme}
{%
  \nointerlineskip%
  \vskip-2pt%
  \hbox{\leavevmode
    \advance\beamer@leftmargin by -12bp%
    \advance\beamer@rightmargin by -12bp%
    \beamer@tempdim=\textwidth%
    \advance\beamer@tempdim by \beamer@leftmargin%
    \advance\beamer@tempdim by \beamer@rightmargin%
    \hskip-\Gm@lmargin\hbox{%
      \setbox\beamer@tempbox=\hbox{\begin{minipage}[b]{\paperwidth}%
          \vbox{}\vskip-.75ex%
          \leftskip0.3cm%
          \rightskip0.3cm plus1fil\leavevmode
          \ifbeamer@nologo
            \ifbeamer@mylogo
              \insertframetitle%
                \pgfdeclareimage[width=1ex,interpolate=true]{ictlogowhite}{ict/mysmall}\hfill\pgfuseimage{ictlogowhite}\hspace{.5ex}%
            \else
              \insertframetitle%
                \pgfdeclareimage[width=1ex,interpolate=true]{ictlogowhite}{ict/ntnu}\hfill\pgfuseimage{ictlogowhite}\hspace{.5ex}%
            \fi
          \else
            \insertframetitle%
              \pgfdeclareimage[width=1ex,interpolate=true]{ictlogowhite}{ict/ntnu}%
          \fi
          \ifx\insertframesubtitle\@empty%
            \strut\par%
          \else
            \par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
          \fi%
          \nointerlineskip
          \vbox{}%
          \end{minipage}}%
      \beamer@tempdim=\ht\beamer@tempbox%
      \advance\beamer@tempdim by 2pt%
      \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
        \usebeamercolor{frametitle right}
        \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
        \pgfusepath{clip}
        \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
      \end{pgfpicture}
      \hskip-\paperwidth%
      \box\beamer@tempbox%
    }%
    \hskip-\Gm@rmargin%
  }%
  \nointerlineskip
    \vskip-0.2pt
    \hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@topshade}\hskip-\Gm@rmargin}
    \vskip-2pt
}



\mode
<all>
